package cn.kow.kmall.controller;

import cn.kow.kmall.core.response.KmallResult;
import cn.kow.kmall.pojo.entity.User;
import cn.kow.kmall.pojo.vo.UserInfoVO;
import cn.kow.kmall.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: lijun
 * @Description:
 * @Date: Created in 2019-05-13 15:27
 * @Modified By:
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping(value = "/info")
    public KmallResult getUserInfo(@RequestAttribute Long uid) {
        User user = userService.getUserByUid(uid);
        UserInfoVO userInfo = new UserInfoVO();
        BeanUtils.copyProperties(user, userInfo);
        return KmallResult.success(userInfo);
    }
}
